#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl "\n"

int p(int num){
    for(int i=2;i<=sqrt(num);i++){
        if(num%i==0)return 0;
    }
    return 1;
}

vector<int>pri;

void solve(){
    vector<int>nums;
    for(int i=0;i<5;i++){
        char c;
        cin>>c;
        nums.push_back(c-'0');
    }
    for(int i=0;i<4;i++){
        if(nums[i]%2==0&&nums[4]!=0){
            swap(nums[i],nums[4]);
            break;
        }
    }
    if(nums[4]%2==0){
        for(int i=0;i<5;i++){
            cout<<nums[i];
        }
        cout<<endl;
    }
    else cout<<97531<<endl;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int _=1;
    cin>>_;
    while(_--){
        solve();
    }
    return 0;
}